package com.behelpful.demo.search.listener;

import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.update.UpdateResponse;
import org.springframework.stereotype.Component;

/**
 * ES 异步更新数据执行监听器
 *
 * @author Alay
 * @date 2021-04-20 19:49
 * @project behelpful
 */
@Slf4j
@Component
public class UpdateListener implements ActionListener<UpdateResponse> {

	@Override
	public void onResponse(UpdateResponse response) {
		log.warn("index:{},异步更新数据成功,action:{},status:{}", response.getIndex(), response.getResult().name(), response.status().name());
	}

	@Override
	public void onFailure(Exception e) {
		log.error("异步添加数据失败,case:{},msg:{}", e.getCause(), e.getMessage());
	}
}